package com.sinochem.yunlian.ship.common.enums;

import java.util.HashMap;

import lombok.Getter;
import lombok.Setter;

/**
 * @Descript 发布方式
 *
 * @Date 2017年12月8日
 */
public enum PublicType {

	PUBLIC_TYPE(0,"公开"),
	
	PRIVATE_PARTNER_TYPE(1,"合作伙伴"),
	
	PRIVATE_CARGO_TYPE(2,"指定货主"),
	
	PRIVATE_SHIP_TYPE(3,"指定船东");
	
	@Getter
	@Setter
	private int code;
	
	@Getter
	@Setter
	private String message;
	
	private PublicType(int code, String message) {
		
		this.code = code;
		
		this.message = message;
	}
	
	/**
	 * 返回值
	 * @param code
	 * @return
	 */
	public static String returnMessage(Integer code) {
		
		if (code == null) {
			return null;
		}
		PublicType[] types = PublicType.class.getEnumConstants();
		HashMap<Integer, String> hashMap = new HashMap<>(10);
		
		for (int i = 0; i < types.length; i++) {
			hashMap.put(types[i].getCode(), types[i].getMessage());;
		}
		
		return hashMap.get(code);
	}

}
